package assignment9.Parcel9;

import assignment9.*;

public class Parcel9 {
    public Destination dest(final String dest, final float price) {
        return new Destination() {
             private int cost;
             private String label;
             {
            	 label = dest;
            	 cost = Math.round(price);
            	 if(cost > 100)
            		 System.out.println("Over budget!");
             } //不能重载的匿名构造
             public String readLabel() { return label; }
        };
    }
    public static void main(String[] args) {
        Parcel9 p = new Parcel9();
        Destination d = p.dest("北京", 101.395F);
        System.out.println(d.readLabel());
    }
}